// FtlThreadPoolDemoDlg.h : header file
//

#pragma once

#include "ftlFake.h"
#include "MyJob.h"

// CFtlThreadPoolDemoDlg dialog
class CFtlThreadPoolDemoDlg 
	: public CDialog
	, public IFThreadPoolCallBack<MyJobParam*>
{
// Construction
public:
	CFtlThreadPoolDemoDlg(CWnd* pParent = NULL);	// standard constructor

// Dialog Data
	enum { IDD = IDD_FTLTHREADPOOLDEMO_DIALOG };

	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support


// Implementation
protected:
	HICON m_hIcon;

	// Generated message map functions
	virtual BOOL OnInitDialog();
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	DECLARE_MESSAGE_MAP()
public:
	CProgressCtrl m_ProgressOfThread;
	LRESULT AFX_MSG_CALL OnThreadUpdateProgress(WPARAM wParam, LPARAM lParam);
	afx_msg void OnBnClickedBtnStart();
	afx_msg void OnBnClickedBtnPauseResume();
	afx_msg void OnBnClickedBtnStop();
	afx_msg void OnDestroy();

	//IFThreadPoolCallBack<MyJobParam*>
	virtual void OnJobBegin(LONG nJobIndex, CFJobBase<MyJobParam*>* pJob );
	virtual void OnJobEnd(LONG nJobIndex, CFJobBase<MyJobParam*>* pJob);
	virtual void OnJobCancel(LONG nJobIndex, CFJobBase<MyJobParam*>* pJob);
	virtual void OnJobProgress(LONG nJobIndex , CFJobBase<MyJobParam*>* pJob, LONG64 nCurPos, LONG64 nTotalSize);
	virtual void OnJobError(LONG nJobIndex , CFJobBase<MyJobParam*>* pJob, DWORD dwError, LPCTSTR pszDescription);

protected:
	void SetThreadButtonStatus(BOOL bStarted, BOOL bPaused);
private:
	LONG	m_nCancelJobIndexFront;
	LONG	m_nJobParamIntValue;
	LONG	m_nHighJobPriority;
	LONG	m_nLowJobPriority;
	LONG	m_nCurJobIndex;

	CFThreadPool<MyJobParam*>*	m_pTestTheradPool;
public:
	afx_msg void OnBnClickedBtnAddjobHigh();
	afx_msg void OnBnClickedBtnAddjobNormal();
	afx_msg void OnBnClickedBtnAddjobLow();
	afx_msg void OnBnClickedBtnCanceljobFront();
	afx_msg void OnBnClickedBtnCanceljobBack();
};
